package com.lcz.mytest.db;


import net.tsz.afinal.FinalHttp;
import net.tsz.afinal.http.AjaxCallBack;

/**
 * Created by Administrator on 2016/3/31.
 */
public class StockAPI {
    //URL
    public static final String HOST = "http://web.juhe.cn:8080/finance/stock/";
    //配置申请的KEY
    public static final String APPKEY = "ba4122b2ca9daa72ee8df4b31e682608";
    static FinalHttp fh = null;

    //获取沪深股市数据
    /*public static void getHS(String gid, Response.Listener<String> listener) {
        StringRequest stringRequest = new StringRequest(HOST + "hs?type=&key=" + APPKEY + "&gid=" + gid,
                listener, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("TAG", error.getMessage(), error);
            }
        });
        getRequestQueue().add(stringRequest);
    }*/

    //1.获取沪深股市数据
    public static void getHS(String gid, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
//        fh.addHeader("key", APPKEY);
        String url = HOST + "hs";
        fh.get(url + "?type=&key=" + APPKEY + "&gid=" + gid, callBack);

    }
    //2.香港股市
    public static void getHK(String gid, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "hk";
        fh.get(url + "?type=&key=" + APPKEY + "&gid=" + gid, callBack);

    }

    //3.美国股市
    public static void getUSA(String gid, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "hkall";
        fh.get(url + "?type=&key=" + APPKEY + "&gid=" + gid, callBack);

    }

    //4.获取香港股市列表数据
    public static void getHKAll(int page, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "hkall";
        fh.get(url + "?type=&key=" + APPKEY + "&page=" + page, callBack);

    }

    //5.获取美国股市列表数据
    public static void getUSAAll(int page, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "usaall";
        fh.get(url + "?type=&key=" + APPKEY + "&page=" + page, callBack);

    }

    //6.获取深圳股市列表数据
    public static void getSZAll(int page, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "szall";
        fh.get(url + "?type=&key=" + APPKEY + "&page=" + page, callBack);
    }

    //7.获取沪股股市列表数据
    public static void getSHAll(int page, AjaxCallBack<String> callBack) {
        fh = new FinalHttp();
        String url = HOST + "shall";
        fh.get(url + "?type=&key=" + APPKEY + "&page=" + page, callBack);

    }

}
